import { Component, OnInit, Input } from "@angular/core";
import { LocaleService, TranslationService, Language } from "angular-l10n";
import { Router } from "@angular/router";

import { Store, select } from "@ngrx/store";
import * as fromUser from "@/user/store/reducers/index";
import * as fromRoot from "@/reducers/index";
import { map, filter, skip } from "rxjs/operators";
import { Subscription } from "rxjs";
import { UserActions } from "@/user/store/actions";
import { combineAll, debounceTime } from "rxjs/operators";

@Component({
  selector: "app-login-tip",
  templateUrl: "./login-tip.component.html",
  styleUrls: ["./login-tip.component.scss"]
})
export class LoginTipComponent implements OnInit {
  @Input()
  type = "";
  @Language() lang: string;
  isLogin$ = this.store.pipe(
    select(fromRoot.userRes),
    filter(e => e.code !== -1),
    map(e => e.code === 200)
  );
  constructor(
    private router: Router,
    private store: Store<fromUser.State | fromRoot.State>
  ) {}

  ngOnInit() {}

  toLogin() {
    this.router.navigate(["u/login"]);
  }

  toEnroll() {
    this.router.navigate(["u/enroll"]);
  }
}
